package com.transaction.controller;


import com.transaction.domain.Order;
import com.transaction.domain.ReturnOrder;
import com.transaction.domain.User;
import com.transaction.service.GoodService;
import com.transaction.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private GoodService goodService;

    @Autowired
    private UserService userService;

    //添加订单
    @RequestMapping("/addOrder")
    public @ResponseBody Boolean addOrder(@RequestBody Order order){
        Boolean status = goodService.order(order);
        return status;
    }

    //订单列表
    @RequestMapping("/orderList")
    public @ResponseBody List<ReturnOrder> orderList(@RequestBody User user){
        System.out.println(user);
        List<ReturnOrder> orders=userService.findOrderListByUid(user.getUid());
        return orders;
    }
}
